package com.luotao.rpc.consumer;

import com.luotao.rpc.provider.UserService;
import com.service.DemoService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by IntelliJ IDEA.
 * User: luotao
 * Date: 12-5-18
 * Time: pm 7:59
 */
public class StartupConsumer {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"consumer.xml"});
        context.start();
        UserService demoService = (UserService) context.getBean("userService"); // 获取远程服务代理
        DemoService dService = (DemoService) context.getBean("demoService");
        for (int i = 0; i < 100; i++) {

            String hello = demoService.sayHello("world"); // 执行远程方法
            System.out.println(hello); // 显示调用结果


            String password = dService.findPassword("lisi");
            System.out.println("password = " + password);
        }

    }
}
